package edu.zju.gis.dbfg.model.statistic;

import lombok.Getter;
import lombok.Setter;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

@Getter
@Setter
public class ClipArgs implements Serializable {
    private final static Logger logger = LoggerFactory.getLogger(ClipArgs.class);

    @Option(name = "-output",usage = "输出文件路径", required = true)
    private String output;

    @Option(name = "-input1",usage = "输入数据,extent", required = true)
    private String input1;

    @Option(name = "-type1",usage = "输入数据类型,extent", required = true)
    private String type1;

    @Option(name = "-input2",usage = "输入数据,target", required = true)
    private String input2;

    @Option(name = "-type2",usage = "输入数据类型,extent", required = true)
    private String type2;

    /**
     * cc码的标志，对于wkt文件，则是数字，对于shapefile文件，则是字段名
     */
    @Option(name = "-areaIndex",usage = "输入数据类型,extent", required = true)
    private String areaIndex;

    @Option(name = "-crs1",usage = "extent crs")
    private String crs1 = "4326";

    @Option(name = "-crs2",usage = "target crs")
    private String crs2 = "4326";

    public  static ClipArgs initArgs(String args[]){
        ClipArgs mArgs = new ClipArgs();
        CmdLineParser parser = new CmdLineParser(mArgs);
        try {
            parser.parseArgument(args);
            return mArgs;
        } catch (CmdLineException e) {
            logger.error(e.getLocalizedMessage());
            return null;
        }
    }
}
